package br.com.playonline.util.bolao;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Criptografia {

	private static final Criptografia INSTANCE = new Criptografia();
	
	private Criptografia() {}
	
	public static Criptografia getInstance(){
		return INSTANCE;
	}
	
	public String encript(String msg){
		String msgEncriptada = "";
		MessageDigest messageDigest;
		
		try {
			messageDigest = MessageDigest.getInstance("MD5");
			messageDigest.update(msg.getBytes(), 0, msg.length());
			msgEncriptada = new BigInteger(1, messageDigest.digest()).toString(16);
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return msgEncriptada;
	}
	
	public static void main(String[] args) {
		String msg = "203142";
		System.out.println(Criptografia.getInstance().encript(msg));
	}
	
}
